﻿using ElasticSearchDemo.Domain.Command;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace ElasticSearchDemo.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class SendMsgController : ControllerBase
    {
        private readonly IMediator _mediator;

        public SendMsgController(IMediator mediator)
        {
            _mediator = mediator;
        }

        [HttpGet, Route("SendMsg")]
        public async Task<bool> SendMsg()
        {
            AddUser addUser = new AddUser();

            return await _mediator.Send(addUser);
        }


        [HttpGet, Route("AddUser")]
        public async Task AddUser()
        {
            RegisterNotification addUser = new RegisterNotification("张三", "12345");

            await _mediator.Publish(addUser);
        }
    }
}
